use sqlx::{Error,Pool,Postgres};
// 这是当不需要返回插&入数据结果时使用的sqlx类型
//use sqlx::postgres::PgQueryResult;

use crate::types::user_types::{User};

/// 查询一条指定的用户数据，返回对应的结构体 手机号，密码，国家方式
pub async fn select_user_login(pool: &Pool<Postgres>, phone: &String, password: &String, country:&String) -> Result<User, Error> {
    sqlx::query_as("SELECT * FROM public.user WHERE phone = $1 AND password = $2 AND country = $3")
        .bind(phone)
        .bind(password)
        .bind(country)
        .fetch_one(pool)
        .await
}